package com.example.music.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Created with IntelliJ IDEA.
 * ClassName: AppConfig
 * Package: com.example.music.config
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-05-29
 * Time: 19:38
 */
@Configuration
public class AppConfig implements WebMvcConfigurer {

    @Bean
    public BCryptPasswordEncoder bCryptPasswordEncoder(){
        return new BCryptPasswordEncoder();
    }

//    //配置拦截器
//    //创建LoginInterceptor 实现HandleInterceptor 重写preHandle 检查是否登录
//    //配置类中配置拦截规则
//    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        LoginInterceptor interceptor = new LoginInterceptor();
//        registry.addInterceptor(interceptor)
//                //所有路径都拦截
//                .addPathPatterns("/**")
//                //排除所有JS
//                .excludePathPatterns("/js/**.js")
//                //排除所有图片文件
//                .excludePathPatterns("/images/**")
//                .excludePathPatterns("/css/**.css")
//                .excludePathPatterns("/player/**")
//                .excludePathPatterns("/login.html")
//                //排除登录接口
//                .excludePathPatterns("/user/login");
//    }
}
